package com.android.djlmapp.adapter.kuandai;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.View;

import com.android.djlmapp.R;
import com.android.djlmapp.activity.kaika.web.TcDetailsActivity;
import com.android.djlmapp.model.kuandai.KuanDaiTcInfo;

import org.refresh_view.pullrecyclerview.BaseRecyclerAdapter;
import org.refresh_view.pullrecyclerview.BaseViewHolder;

import java.util.ArrayList;

/**
 * 宽带地质数据适配器
 */

public class KuanDaiTaoCanAdapter extends BaseRecyclerAdapter<KuanDaiTcInfo.TcListBean> {
    private Activity activity;

    public KuanDaiTaoCanAdapter(Context context) {
        super(context, R.layout.item_selecttc_kuandai, new ArrayList<KuanDaiTcInfo.TcListBean>());
        this.activity = (Activity) context;
    }

    @Override
    protected void convert(BaseViewHolder holder, KuanDaiTcInfo.TcListBean item) {

        holder.setText(R.id.kd_tv_tc_name, item.getSpec_1() + "  " + item.getSpec_2());
        holder.setText(R.id.tv_tc_price, "¥ " + item.getSale_price());

        // 跳转详情
        holder.setOnClickListener(R.id.kd_iv_go_tcxq, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                activity.startActivity(new Intent(activity, TcDetailsActivity.class).
                        putExtra("SPCID", item.getSpec_id1()));
            }
        });

        // 条目点击事件
        holder.setOnClickListener(R.id.ll_kd_tc, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mOnItemClickListener.onItemClick(item);
            }
        });
    }


    public OnItemClickListener mOnItemClickListener;

    public interface OnItemClickListener {
        void onItemClick(KuanDaiTcInfo.TcListBean item);
    }

    public void setOnItemClickListener(OnItemClickListener mOnItemClickLitener) {
        this.mOnItemClickListener = mOnItemClickLitener;
    }

}
